/* Thread.cc -- Classe para encapsular thread
 *
 * Copyright (C) 2008, Diogo F. S. Ramos <diogo.ramos@usp.br>
 * GEAR - Grupo de Estudos Avançados em Robótica
 * <http://www.sel.eesc.usp.br/gear>
 *
 * This file is part of GearIA.
 * 
 * GEARMedula is free software: you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation, version 3 of the
 * License.
 * 
 * GEARMedula is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see
 * <http://www.gnu.org/licenses/>.
 */

#ifndef THREAD_HH_
#define THREAD_HH_

#include <pthread.h>

class Thread
{
public:
    Thread();
    ~Thread();
    int Start(void * arg);
    void Stop(void);
protected:
    int Execute(void * arg);
    static void * EntryPoint(void*);
    virtual void Run(void*) = 0;
    void * getArg() const {return Arg_;}
    void Arg(void* a){Arg_ = a;}
private:
    pthread_t thread_id_;
    void * Arg_;
};

#endif
